﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Serilog;

namespace S.EarTag.API
{
    public class MyExec : IAsyncExceptionFilter
    {
        /// <summary>
        /// 写过滤器方法
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Task OnExceptionAsync(ExceptionContext context)
        {
            if (!context.ExceptionHandled)
            {
                context.Result = new ContentResult()
                {
                    Content = "服务器加载异常，请重试......",
                };
            }
            Log.Debug(context.Exception.Message);
            context.ExceptionHandled = true;
            return Task.CompletedTask;
        }
    }
}
